cached       = require 'gulp-cached'
coffeeStream = require '../utils/coffeeStream.coffee'
concat       = require 'gulp-concat'
gulp         = require 'gulp'
merge        = require('merge-stream')
paths        = require('../config.coffee').paths
remember     = require 'gulp-remember'
sourcemaps   = require 'gulp-sourcemaps'

gulp.task 'scripts', ->
    merge(
            gulp.src(paths.scripts[0])
            .pipe(sourcemaps.init())
            .pipe(cached('coffeeCache'))
            .pipe(coffeeStream())
            .pipe(remember('coffeeRem')),
            gulp.src(paths.scripts[1])
    )
        .pipe(concat('app.js'))
        .pipe sourcemaps.write('.')
        .pipe(gulp.dest(paths.dest))
